#ifndef __PYTHON_EXCEPTION_H__
#define __PYTHON_EXCEPTION_H__

#include <sstream>
#include <string>

#define THROW(E) throw E()
#define THROW_M(E, M) throw E(M, __FILE__, __LINE__)

class BaseException {
public:
	BaseException() {
		msg = "";
		file = "";
		line = 0;
	}
	BaseException(const char* s) {
		msg = s;
		file = "";
		line = 0;
	}
	BaseException(const char* s, const char* f, int l) {
		msg = s;
		file = f;
		line = l;
	}
	const char* getMessage() {
		stringstream ss;
		ss << msg << " (" << file << ":" << line << ")";
		return ss.str().c_str();
	}

protected:
	string msg;
	string file;
	int line;
};

class PyException : public BaseException {
public:
	PyException() {
		msg = "";
		file = "";
		line = 0;
	}
	PyException(const char* s) {
		msg = s;
		file = "";
		line = 0;
	}
	PyException(const char* s, const char* f, int l) {
		msg = s;
		file = f;
		line = l;
	}
};

#endif /* __PYTHON_EXCEPTION_H__ */
